import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
/* 布局 */
import Layout from "@/layout/index.vue"

/**
 * Note:  子路由 children.length >= 1 子菜单显示
 *
 * hidden: true                   设置true,不显示在侧边栏(默认:false)
 * alwaysShow: true               设置true,显示根菜单. 如果不设置alwaysShow,分类下有子分类会显示根菜单,没有则不显示.
 * redirect: noRedirect           如果设置noRedirect,面包屑将不重定向
 * name:'router-name'             name用于 <keep-alive> (必须设置!!!)
 * meta : {
	roles: ['admin','editor']    控制页面角色 (你可以设置多个角色)//目前通过自定义指令替换此方法
	permission: ['ACTION1','ACTION2']   控制权限(权限值与接口返回权限值匹配上则显示相应分类)
	title: 'title'               名字显示在侧边栏和导航(推荐设置)
	icon: 'svg-name'             侧边栏的图标显示
	breadcrumb: false            设置false, 该项在面包屑上隐藏(默认true)
	activeMenu: '/example/list'  设置path, 侧边栏高亮显示你设置的path
  }
 */

/**
 * 路由配置
 * 不设置permission的都可访问; 设置了permission,需满足对应权限才可访问
 */
export const constantRoutes = [{
		path: "/login",
		component: () => import("@/views/login/index.vue"),
		hidden: true
	},
	{
		path: "/404",
		component: () => import("@/views/404.vue"),
		hidden: true
	},
	{
		path: '/',
		component: Layout,
		redirect: '/casting',
		name: 'Dashboard',
		meta: { title: '首页', icon: 'HomeFilled' },
		permission: [''],
		children: [{
				path: 'casting',
				name: 'Casting',
				component: () => import("@/views/dashboard/casting.vue"),
				meta: { title: '浇铸总图' },
				permission: ['']
			},
			{
				path: '/slicings',
				meta: { title: '在线切割图' },
				redirect: '/slicing',
				permission: [''],
				children: [{
						path: 'slicing',
						name: 'Slicing',
						component: () => import("@/views/dashboard/slicing.vue"),
						meta: { title: '在线切割图', breadcrumb: false },
						permission: ['']
					},
					{
						hidden: true,
						path: 'slicingDetails',
						name: 'SlicingDetails',
						component: () => import("@/views/dashboard/slicingDetails.vue"),
						meta: { title: '切割示意图' },
						permission: ['']
					}
				]
			},
		]
	},
	{
		path: '/produceTracking',
		component: Layout,
		redirect: '/produceTracking/heatSchedule',
		name: 'ProduceTracking',
		meta: { title: '生产跟踪', icon: 'Briefcase' },
		permission: [''],
		children: [{
				path: 'heatSchedule',
				name: 'HeatSchedule',
				component: () => import("@/views/produceTracking/heatSchedule.vue"),
				meta: { title: '炉次计划' },
				permission: ['']
			},
			{
				path: 'furnacePerformance',
				name: 'FurnacePerformance',
				component: () => import("@/views/produceTracking/furnacePerformance.vue"),
				meta: { title: '炉次实绩' },
				permission: ['']
			},
			{
				path: 'castBilletPerformance',
				name: 'CastBilletPerformance',
				component: () => import("@/views/produceTracking/castBilletPerformance.vue"),
				meta: { title: '铸坯实绩' },
				permission: ['']
			},
			{
				path: '/productionOperation',
				meta: { title: '出坯操作' },
				permission: [''],
				children: [{
						path: '/productionOperation',
						name: 'ProductionOperation',
						component: () => import("@/views/produceTracking/productionOperation.vue"),
						meta: { title: '出坯操作', breadcrumb: false },
						permission: ['']
					},
					{
						hidden: true,
						path: 'productionSpraying',
						name: 'ProductionSpraying',
						component: () => import("@/views/produceTracking/productionSpraying.vue"),
						meta: { title: '喷号管理' },
						permission: ['']
					}
				]
			}
		]
	},
	{
		path: '/processModel',
		component: Layout,
		redirect: '/processModel/QESModel',
		name: 'ProcessModel',
		meta: { title: '工艺模型', icon: 'HelpFilled' },
		permission: [''],
		children: [{
				path: 'QESModel',
				name: 'QESModel',
				component: () => import("@/views/processModel/QESModel.vue"),
				meta: { title: 'QES模型' },
				permission: ['']
			},
			{
				path: 'QESCastingResults',
				name: 'QESCastingResults',
				component: () => import("@/views/processModel/QESCastingResults.vue"),
				meta: { title: 'QES-铸坯结果' },
				permission: ['']
			},
			{
				path: 'cuttingOptimization',
				name: 'CuttingOptimization',
				component: () => import("@/views/processModel/cuttingOptimization.vue"),
				meta: { title: '切割优化' },
				permission: ['']
			},
			{
				path: 'mixedSteelModel',
				name: 'MixedSteelModel',
				component: () => import("@/views/processModel/mixedSteelModel.vue"),
				meta: { title: '混钢模型' },
				permission: ['']
			},
			{
				path: 'mixedSteelProcessSetting',
				name: 'MixedSteelProcessSetting',
				component: () => import("@/views/processModel/mixedSteelProcessSetting.vue"),
				meta: { title: '混钢工艺设置' },
				permission: ['']
			}
		]
	},
	{
		path: '/statistics',
		component: Layout,
		redirect: '/statistics/produce',
		name: 'Statistics',
		meta: { title: '生产统计', icon: 'TrendCharts' },
		permission: [''],
		children: [{
				path: 'produce',
				name: 'Produce',
				component: () => import("@/views/statistics/produce.vue"),
				meta: { title: '浇次产出统计' },
				permission: ['']
			},
			{
				path: 'QESStatistics',
				name: 'QESStatistics',
				component: () => import("@/views/statistics/QESStatistics.vue"),
				meta: { title: 'QES统计' },
				permission: ['']
			},
			{
				path: '/productionReport',
				meta: { title: '生产报表' },
				redirect: '/productionReport',
				permission: [''],
				children: [{
						path: 'productionReport',
						name: 'ProductionReport',
						component: () => import("@/views/statistics/productionReport.vue"),
						meta: { title: '生产报表', breadcrumb: false },
						permission: ['']
					},
					{
						hidden: true,
						path: 'productionReportDetails',
						name: 'ProductionReportDetails',
						component: () => import("@/views/statistics/productionReportDetails.vue"),
						meta: { title: '生产报表详情' },
						permission: ['']
					}
				]
			},
			{
				path: 'reportConfiguration',
				name: 'ReportConfiguration',
				component: () => import("@/views/statistics/reportConfiguration.vue"),
				meta: { title: '生产报表配置' },
				permission: ['']
			}
		]
	},
	{
		path: '/maintenance',
		component: Layout,
		redirect: '/maintenance/steelType',
		name: 'Maintenance',
		meta: { title: '工艺维护', icon: 'Tools' },
		permission: [''],
		children: [{
				path: 'steelType',
				name: 'SteelType',
				component: () => import("@/views/maintenance/steelType.vue"),
				meta: { title: '钢种管理' },
				permission: ['']
			},
			{
				path: 'crossSection',
				name: 'CrossSection',
				component: () => import("@/views/maintenance/crossSection.vue"),
				meta: { title: '断面管理' },
				permission: ['']
			},
			{
				path: 'cutToLength',
				name: 'CutToLength',
				component: () => import("@/views/maintenance/cutToLength.vue"),
				meta: { title: '定尺管理' },
				permission: ['']
			},
			{
				path: 'QESRule',
				name: 'QESRule',
				component: () => import("@/views/maintenance/QESRule.vue"),
				meta: { title: 'QES规则管理' },
				permission: ['']
			}
		]
	},
	{
		path: '/account',
		component: Layout,
		redirect: '/account/steelType',
		name: 'Account',
		meta: { title: '账户管理', icon: 'Avatar' },
		permission: [''],
		children: [{
				path: 'systemSettings',
				name: 'SystemSettings',
				component: () => import("@/views/account/systemSettings.vue"),
				meta: { title: '系统设置' },
				permission: ['']
			},
			{
				path: 'permissionGroup',
				name: 'PermissionGroup',
				component: () => import("@/views/account/permissionGroup.vue"),
				meta: { title: '权限组' },
				permission: ['']
			},
			{
				path: 'manageAccount',
				name: 'ManageAccount',
				component: () => import("@/views/account/manageAccount.vue"),
				meta: { title: '管理账户' },
				permission: ['']
			},
			{
				path: 'changePassword',
				name: 'ChangePassword',
				component: () => import("@/views/account/changePassword.vue"),
				meta: { title: '修改密码' },
				permission: ['']
			}
		]
	},
	// 404页面必须放置在结束 !!!
	{
		path: '/:pathMatch(.*)',
		redirect: '/404',
		hidden: true
	}
];

const router = createRouter({
	history: createWebHashHistory(),
	routes: constantRoutes
})


export function resetRouter() {
	const newRouter = createRouter();
	router.matcher = newRouter.matcher; // 重置router
}

export default router